Double free in sec_pkcs7_decoder_start_decrypt()
Categories
(NSS :: Libraries, defect, P3)
Tracking
(firefox-esr115 wontfix, firefox-esr128135+ fixed, firefox131 wontfix, firefox132 wontfix, firefox133 fixed)
People
(Reporter: mozillabugs, Assigned: KaiE)
References
Details
(4 keywords, Whiteboard: [post-critsmash-triage][adv-main133+][adv-ESR128.7+])
Attachments
(2 files)
sec_pkcs7_decoder_start_decrypt()
(security/nss/lib/pkcs7/p7decode.c
) calls PK11_FreeSymKey()
twice for the same key on an error path. The issue occurs if line 538-9 fails, returning NULL
. Line 544 then unconditionally frees bulkkey
, the condition on line 546 is true
, and line 549 transfers control to line 562. Line 563 then frees bulkkey
again.
sec_pkcs7_decoder_start_decrypt()
is linked into the FF executable, but I haven't found where FF uses it. It is definitely used by TBird for S/MIME.
Code from FIREFOX_126_0_RELEASE
:
468: static SECStatus
469: sec_pkcs7_decoder_start_decrypt(
...
473: {
474: PK11SymKey *bulkkey = NULL;
...
538: decryptobj = sec_PKCS7CreateDecryptObject(bulkkey,
539: &(enccinfo->contentEncAlg));
540:
541: /*
542: * We are done with (this) bulkkey now.
543: */
544: PK11_FreeSymKey(bulkkey);
545:
546: if (decryptobj == NULL) {
547: p7dcx->error = PORT_GetError();
548: PORT_SetError(0);
549: goto no_decryption;
550: }
...
562: no_decryption:
563: PK11_FreeSymKey(bulkkey);
...
579: }
I'm working on a POC.
Comment 1•1 year ago
|
||
I haven't found where FF uses
I don't see any code coverage of this in Firefox, either. We do use PKCS7 for signing addons, but not encrypting as far as I know.
Double-free in pretty straight line code is probably fine most of the time, but there's a chance something reallocates that space in the tiny bit of time between line 544 and the jump to line 562
Updated•1 year ago
|
Updated•11 months ago
|
Assignee | ||
Comment 2•8 months ago
|
||
Updated•8 months ago
|
Assignee | ||
Comment 3•8 months ago
|
||
Is there a tracking flag for NSS patches that could potentially get backported to the branch used by ESR?
Might be nice to backport for Thunderbird 128 branch / NSS 3.101.x as a ride along, if another 3.101.x release is made.
Assignee | ||
Comment 4•8 months ago
|
||
Do you have any preference for timing the commit to NSS, given a release was just cut?
Commit now, or wait until we're closer to the next NSS release?
Assignee | ||
Comment 5•7 months ago
|
||
Updated•7 months ago
|
Updated•7 months ago
|
Updated•7 months ago
|
Updated•7 months ago
|
Updated•7 months ago
|
Comment 6•7 months ago
|
||
Updated•6 months ago
|
Updated•4 months ago
|
Updated•4 months ago
|
Updated•2 months ago
|
Description
•